<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<jsp:include page="/scripts/common/index.html"></jsp:include>
<jsp:include page="/scripts/dhtmlx/index.html"></jsp:include>
<jsp:include page="/scripts/jquery/index.html"></jsp:include>
<jsp:include page="/scripts/bootstrap/index.html"></jsp:include>
<link rel="stylesheet" href="${basepath }style/default.css">
</head>
<script type="text/javascript">
	var temp = false;
	function save() {
		var url = '${basePath}/page/workflow/deploy/DeployManage/doAdd';
		var data = {
			"map.fileId" : $("#wfFileId").val()
		};
		$.ajax({
				type : 'POST' ,
				url : url ,
				data : data ,
				dataType : "json" ,
				async : true ,
				cache : false ,
				jsonpCallback : "jsonpCallback" ,
				success : function(response, status, statusText) {
					//alert(response + ":" + status + ":" + statusText);
					alert(response.content);
					closeWindow();
				}
		});
	}
	function query() {
		parent.query();
	}
	function closeWindow() {
		parent.w1.close();
	}
	$(document).ready(function() {
		// Generate a simple captcha
		function randomNumber(min, max) {
			/* alert(Math.floor(Math.random() * (max - min + 1) + min)); */
			return Math.floor(Math.random() * (max - min + 1) + min);
		}
		;
		/* $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' ')); */
		$('#MyForm').bootstrapValidator({
				message : 'This value is not valid' ,
				icon : {
						valid : 'glyphicon glyphicon-ok' ,
						invalid : 'glyphicon glyphicon-remove' ,
						validating : 'glyphicon glyphicon-refresh'
				} ,
				fields : {
					"wfFile" : {
							row : '.col-xs-3' ,
							validators : {
								notEmpty : {
									message : '文件不能为空'
								}
							}
					}
				}
		}).on('success.form.bv', function(e) {
			// 			alert("验证成功");
			temp = true;
			return temp;
		}).on('error.form.bv', function(e) {
			alert("验证失败");
			temp = false;
			return temp;
		});
	});
</script>
<script type="text/javascript">
	//	getDeployments
	$(function() {
		$("#wfFileId").change(function() {
			//流程图预览后期实现 url : 'page/workflow/deploy/DeployManage/getPicPreview' ,
		});
		fn_setFileGroupId("workflow");
	});
	//4e4a7427-2443-473b-b987-d0c2c3b93066.bpmn
	function getFile(obj) {
		var fileList = obj["rs_fileList"];
		$(fileList).each(function(i, o) {
			console.debug(o);
			$("#wfFileId").val(o.id);
		});
	}
</script>
<body>
	<form class="form-horizontal MyForm" id="MyForm" name="MyForm" method="post" target="MyFrame" enctype="multipart/form-data">
		<table class="contTable">
			<tr class="firstTr">
				<td>
					<%-- <jsp:include page="/common/FileUpload_Toolbar.jsp">
						<jsp:param name="accept" value="application/bpmn" />
						<jsp:param name="fn_getFile" value="getFile" />
						<jsp:param name="fn_setFormGuid" value="setFormGuid" />
					</jsp:include> --%>
					<jsp:include page="/common/FileUpload_Toolbar.jsp">
						<jsp:param name="accept" value="applicationmn" />
						<jsp:param name="fn_getFile" value="getFile" />
						<jsp:param name="fn_setFileGroupId" value="fn_setFileGroupId" />
						<jsp:param name="fn_getFileGroupId" value="fn_getFileGroupId" />
					</jsp:include>
					
					<button onclick="save()" class="btn btn-primary" type="button">
						<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
						&nbsp;
						<span>确认部署</span>
					</button>
					<button onclick="closeWindow()" class="btn btn-primary" type="button">
						<span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span>
						&nbsp;
						<span>关闭</span>
					</button>
				</td>
			</tr>
			<tr style="height:auto">
				<td valign="top">
					<div style="width:100%;overflow-y:auto;">
						<div class="blockBorder">
							<div class="titleS">
								<strong>流程部署</strong>
							</div>
							<div class="tableCont" style="width: 90%;">
								<div class="form-group">
									<label class="col-xs-4 control-label" style="float: left;" for="wfFile">流程文件ID:</label>
									<div class="col-xs-6 ">
										<input class=" form-control" name="wfFileId" id="wfFileId" type="text" placeholder="" value="" />
									</div>
									<span class="required">*</span>
								</div>
								<div class="form-group">
									<label class="col-xs-4 control-label" style="float: left;" for="wfFile">流程文件名称:</label>
									<div class="col-xs-6 ">
										<input class=" form-control" name="wfFileName" id="wfFileName" type="text" placeholder="" value="" />
									</div>
									<span class="required">*</span>
								</div>
							</div>
						</div>
					</div>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
